<!-- @format -->

<template>
  <view class="tree-menu">
    <tree-item
      v-for="(item, idx) in tree"
      :key="idx + item.direction"
      :item="item"
      :current-path="currentPath"
      :expand="item.direction && idx === 0"
      @select="handleSelect"
    />
  </view>
</template>

<script lang="ts" setup>
import { defineProps, ref } from 'vue'
import TreeItem from './TreeItem.vue'

const props = defineProps<{
  tree: any
}>()

const currentPath = ref('')
const emit = defineEmits(['select'])

const handleSelect = (file: any) => {
  currentPath.value = file.path
  emit('select', file)
}
</script>

<style scoped>
.tree-menu {
  padding: 10px;
  background-color: #f9f9f9; /* 背景颜色 */
}
</style>
